/**
 * 
 */
package com.qachecklist.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * Environment in which the test was done.
 * 
 * Examples: Operating System, Browser
 * and/or hardware specifications
 * 
 * @author hirokiterashima
 */
@Entity
@Table(name="environments")
public class Environment extends PersistableDomain {

	protected static String fromQuery = "from Environment";

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id = null;
	
	@Column(name="name")
    private String name;  // short-hand name to refer to this environment
	
	@Column(name="description")
	private String description;  // description of this environment

    public Long getId() {
        return id;
    }

    @SuppressWarnings("unused")
	private void setId(Long id) {
        this.id = id;
        
    }

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	protected Class<Environment> getObjectClass() {
		return Environment.class;
	}
	
	@Override
	public String toXMLString() {
		return 
			"<environment><id>"+ this.getId() +"</id>"
			+ "<name>" + this.getName() + "</name>"
			+ "<description>" + this.getDescription() + "</description>"
			+ "</environment>";
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		if (args[0].equals("store")) {
			Environment env = new Environment();
			env.setDescription("test description");
			env.setName("test name");
			env.saveOrUpdate();
		}
		else if (args[0].equals("list")) {
			List<Environment> envs = (List<Environment>) Environment.getList(Environment.class);
			for (Environment env : envs) {
				System.out.println("Environment: " + env.getName() + " Description:" + env.getDescription());
			}
		}
	}

}
